#COMILATION OF 3 FILES 

#COMPILATOR
CC = gcc 

# EXECUTABLES NAME
EXECNAME_1 = game_gfx
EXECNAME_2 = game_txt
EXECNAME_3 = game_test

#OS = WIN32
OS = LINUX

ifeq ($(OS),WIN32) 
INCLUDE_DIR = -Isrc -I"D:\MingW\PDCurses" -I"D:\MingW\SDL\include\SDL"
else
INCLUDE_DIR = -I/usr/include -Isrc -I/usr/include/SDL
endif

# SOURCE FILES AND LIBS FOR EXECUTABLES
SRCFILES_1 = Hero.c Game.c Monster.c SDLGame.c Terrain.c main.c Spell.c TableauDynamique.c Teleport.c

# WINDOWS OR LINUX?
ifeq ($(GAME)$(OS),WIN32)
LIBS_1 = -L"D:\MingW\SDL\lib" -lmingw32 -lSDLmain -lSDL.dll
else
LIBS_1 = -lSDL -lSDL_ttf -lSDL_image #-lSDL_mixer
endif

SRCFILES_2 = Hero.c Game.c Monster.c Ncurs.c Terrain.c main.c Spell.c TableauDynamique.c Teleport.c

# WINDOWS OR LINUX?
ifeq ($(GAME)$(OS),WIN32)
LIBS_2 = -lpdcurses
else
LIBS_2 = -lncurses
endif

SRCFILES_3 = Hero.c Game.c Monster.c Terrain.c main.c Spell.c TableauDynamique.c Teleport.c
LIBS_3 = 


#DEBUGGING FLAGS
DBG = -ggdb

#OTHER PARAMETERS
PARAMS = -Wall -pedantic -ansi $(DBG) $(INCLUDE_DIR)

#PROJECT FOLDERS
OBJ_DIR = obj
SRC_DIR = src
BIN_DIR = bin

all: $(BIN_DIR)/$(EXECNAME_1) $(BIN_DIR)/$(EXECNAME_2) $(BIN_DIR)/$(EXECNAME_3)

$(BIN_DIR)/$(EXECNAME_1): $(SRCFILES_1:%.c=$(OBJ_DIR)/%.o)
	$(CC) $+ -o $@ $(PARAMS) $(LIBS_1)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
	$(CC) -o $@ -c $< $(PARAMS) -DSDL -D$(OS)

$(BIN_DIR)/$(EXECNAME_2): $(SRCFILES_2:%.c=$(OBJ_DIR)/%2.o)
	$(CC) $+ -o $@ $(PARAMS) $(LIBS_2)

$(OBJ_DIR)/%2.o: $(SRC_DIR)/%.c
	$(CC) -o $@ -c $< $(PARAMS) -DBOUCLE -D$(OS)

$(BIN_DIR)/$(EXECNAME_3): $(SRCFILES_3:%.c=$(OBJ_DIR)/%3.o)
	$(CC) $+ -o $@ $(PARAMS) $(LIBS_3)

$(OBJ_DIR)/%3.o: $(SRC_DIR)/%.c
	$(CC) -o $@ -c $< $(PARAMS) -DTEST -D$(OS)


.PHONY: clean

clean:
	rm -rf $(OBJ_DIR)/*.o $(BIN_DIR)/$(EXECNAME_1) $(BIN_DIR)/$(EXECNAME_2) $(BIN_DIR)/$(EXECNAME_3)

